//
//  NSArray+Extension.h
//  YunDaHome-iOS
//
//  Created by 刘权 on 2020/1/15.
//  Copyright © 2020 YunDa. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface NSArray (Extension)

/// 安全地取值，若越界取nil
- (id)j_objectAtIndex:(NSUInteger)index;

/// 随机返回一个对象 (如果Array空，则返回nil)
- (id)j_randomObject;


@end

@interface NSMutableArray(Extension)

/// 安全地追加object
- (void)j_addObject:(id)obj;

/// 追加CGPoint
- (void)j_addPoint:(CGPoint)point;

/// 追加CGSize
- (void)j_addSize:(CGSize)size;

/// 追加CGRect
- (void)j_addRect:(CGRect)rect;

/// 在某个位置添加一批对象 (index不能超出范围)
- (void)j_insertObjects:(NSArray *)objects atIndex:(NSUInteger)index;

/// 反转对象顺序，例如 @[ @1, @2, @3 ] -> @[ @3, @2, @1 ].
- (void)j_reverse;

/// 随机排列对象顺序 (洗牌)
- (void)j_shuffle;

@end

NS_ASSUME_NONNULL_END
